
function insertCss(cs) {
    var el = document.createElement('link');
    el.setAttribute('rel', 'stylesheet');
    el.setAttribute('href', chrome.runtime.getURL(cs));
    document.head.appendChild(el);
}

function insertJs(js) {
    var script = document.createElement('script');
    script.setAttribute('src', chrome.runtime.getURL(js));
    script.type='text/javascript';
    document.head.appendChild(script);
}

function inject_iReaderBar() {
    let ful_scr_toolbar = document.createElement("div");
    ful_scr_toolbar.className = "ful_scr_toolbar_notful";

    let ful_scr_toolbar_close = document.createElement("a");
    ful_scr_toolbar_close.textContent = "+";
    ful_scr_toolbar.appendChild(ful_scr_toolbar_close);
    document.body.appendChild(ful_scr_toolbar);

    let ful_scr_toolbar_icon = document.createElement("div");
    ful_scr_toolbar_icon.className = "ful_scr_toolbar_icon";
    ful_scr_toolbar_icon.id = "ireader_donate_icon";

    let ireader_icon = document.createElement("img");
    ireader_icon.src = chrome.runtime.getURL('images/simbaba.png');
    ful_scr_toolbar_icon.appendChild(ireader_icon);

    document.body.appendChild(ful_scr_toolbar);
    document.body.appendChild(ful_scr_toolbar_icon);

    return {ful_scr_toolbar,ful_scr_toolbar_close,ful_scr_toolbar_icon}
}

function showDonate(show) {
    chrome.storage.sync.get(['donate'], function(result) {
        let donate = document.getElementById("ireader_donate_icon")
        if (!result.donate){
            donate.style.display = "none";
            return
        }
        if (show) {
            donate.style.display = "block";
            setTimeout(()=>{donate.style.display = "none"}, 4000)
        }
    })
}